﻿<%@ Page Title="" Language="C#" MasterPageFile="~/CommonChat/CommonChat.master" AutoEventWireup="true" CodeBehind="ChatManage.aspx.cs" Inherits="chatblog.CommonChat.ChatManage" %>

<%@ Register Assembly="RuleCode.Common" Namespace="RuleCode.Controls" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContentPlaceHolder" runat="server">
    <style  type ="text/css" >
   #con {
	FONT-SIZE: 12px; MARGIN: 0px auto; WIDTH:100% ; 
}
#tags {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 10px; WIDTH: 100%; PADDING-TOP: 0px; HEIGHT: 23px
}
#tags LI {
	BACKGROUND: url(img/tagleft.gif) no-repeat left bottom; FLOAT: left; MARGIN-RIGHT: 1px; LIST-STYLE-TYPE: none; HEIGHT: 23px
}
#tags LI A {
	PADDING-RIGHT: 10px; PADDING-LEFT: 10px; BACKGROUND: url(img/tagright.gif) no-repeat right bottom; FLOAT: left; PADDING-BOTTOM: 0px; COLOR: #999;LINE-HEIGHT: 23px; PADDING-TOP: 0px; HEIGHT: 23px; TEXT-DECORATION: none
}
#tags LI.emptyTag {
	BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 4px
}
#tags LI.selectTag {
	BACKGROUND-POSITION: left top; MARGIN-BOTTOM: -2px; POSITION: relative; HEIGHT: 25px
}
#tags LI.selectTag A {
	BACKGROUND-POSITION: right top; COLOR: #000; LINE-HEIGHT: 25px; HEIGHT: 25px
}
#tagContent {
	BORDER-RIGHT: #aecbd4 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #aecbd4 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: #aecbd4 1px solid;PADDING-TOP:1px; BORDER-BOTTOM: #aecbd4 1px solid; BACKGROUND-COLOR: #fff
}
.tagContent {
PADDING-RIGHT: 10px; DISPLAY: none; PADDING-LEFT: 10px;  PADDING-BOTTOM: 10px; WIDTH:98%; COLOR: #474747; PADDING-TOP: 10px; HEIGHT: 370px;
}
#tagContent DIV.selectTag {
DISPLAY: block
}

.chatroomList
{
    border :solid 1px #ECECEC;
    width :200px;
    height :360px;
}
.chatToolButton
{
    margin-top :2px;
}
.datalist
{
    vertical-align:top ;
}
</style> 

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">
        
    <div id="con">
        <ul id="tags">
          <li><A onclick="selectTag('tagContent0',this)"  href="javascript:void(0)">私人聊天室</A> </li>
          <li><A onclick="selectTag('tagContent1',this)"  href="javascript:void(0)">公共聊天室</A> </li>
        </ul>
        <div id="tagContent" style =" height :400px">
            <%--私人聊天室--%>
            <div class="tagContent selectTag" id="tagContent0"> 
                 <table>
                    <tr>
                        <td>
                            在线的私人聊天室<br/>
                            <table style=" width :300px; height :20px; background-color :lightGray">
                                <tr>
                                    <td style ="width :10%; height :20px"></td>
                                    <td style =" width :50%; height :20px">创建者ID</td>
                                    <td style =" width :40%; height :20px">创建者昵称</td>
                                </tr>
                            </table>
                            <asp:DataList ID="PersonalChatDataList" runat="server" BorderStyle ="Solid" BorderColor ="#ECECEC" BorderWidth ="1px" 
                                Width ="300px"  DataKeyField ="RECID">
                                <ItemTemplate>
                                    <table  onmouseover ="this.bgColor='lightBlue';" onmouseout ="this.bgColor='';" style=" width :100%; height :20px">
                                        <tr>
                                            <td style ="width :10%; height :20px"><input  type ="checkbox"  id="selectPersonalChat" /></td>
                                            <td style =" width :50%; height :20px"><%#Eval("cbuserid") %></td>
                                            <td style =" width :40%; height :20px"><%#Eval ("cbname") %></td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                            </asp:DataList>
                            <cc1:WebPager ID="PersonalChatWebPager" ControlToPaginate ="PersonalChatDataList" PageSize ="15"
                                OnPageIndexChanged ="PersonalChatWebPager_PageIndexChanged" PagerStyle ="NumericPages"    runat="server" />
                            <div style =" width :100%; background-color :lightGray; height :30px; vertical-align :middle ;">
                                <input  type ="button"  value="全选" class ="chatToolButton " onclick ="chatSelectAll(personalDataListId);"/>
                                <input  type ="button"  value="反选" class ="chatToolButton " onclick ="chatSelectOthers(personalDataListId);"/>
                                <input  type ="button"  value="强制下线" class ="chatToolButton " onclick ="personalForceUnline();"/>
                            </div>
                        </td>
                        <td>
                        </td>
                    </tr>
                 </table>          
            </div>
            
            <%--公共聊天室--%>
            <div class="tagContent" id="tagContent1">  
                <table>
                    <tr>
                        <td>
                            在线的公共聊天室<br/>
                            <table style=" width :300px; height :20px; background-color :lightGray">
                                <tr>
                                    <td style ="width :10%; height :20px"></td>
                                    <td style =" width :20%; height :20px">聊天ID</td>
                                    <td style =" width :40%; height :20px">聊天室名称</td>
                                    <td style =" width :30%; height :20px">创建者</td>
                                </tr>
                            </table>
                            <asp:DataList ID="CommonChatDataList" runat="server" BorderStyle ="Solid" BorderColor ="#ECECEC" BorderWidth ="1px" 
                                Width ="300px"   CssClass ="datalist" DataKeyField ="RoomID">
                                <ItemTemplate>
                                    <table title ="点击查看聊天室的用户" id='<%#Eval("RoomID") %>' onclick ="selectedRoomID(this);"  onmouseover ="this.bgColor='lightBlue';" onmouseout ="this.bgColor='';" style=" width :100%; height :20px">
                                        <tr>
                                            <td style ="width :10%; height :20px"><input  type ="checkbox"  id="selectCommonChat" /></td>
                                            <td style =" width :20%; height :20px"><%#Eval("RoomType")%></td>
                                            <td style =" width :30%; height :20px"><%#Eval("RoomName")%></td>
                                            <td style =" width :30%; height :20px"><%#Eval("NickName")%></td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                            </asp:DataList>
                            <cc1:WebPager ID="CommonChatWebPager" ControlToPaginate ="CommonChatDataList" PageSize ="15"
                                OnPageIndexChanged ="CommonChatWebPager_PageIndexChanged" PagerStyle ="NumericPages"    runat="server" />
                            <div style =" width :100%; background-color :lightGray; height :30px; vertical-align :middle ;">
                                <input  type ="button"  value="全选" class ="chatToolButton " onclick ="chatSelectAll(commonDataListId);"/>
                                <input  type ="button"  value="反选" class ="chatToolButton " onclick ="chatSelectOthers(commonDataListId);"/>
                                <input  type ="button"  value="强制下线" class ="chatToolButton " onclick ="commonForceChatUnline();"/>
                            </div>
                        </td>
                        <td style =" width :50px;">
                            
                        </td>
                        <td style =" vertical-align :top ">
                            聊天室中的用户<br/>
                            <table style=" width :300px; height :20px; background-color :lightGray">
                                <tr>
                                    <td style ="width :10%; height :20px"></td>
                                    <td style =" width :30%; height :20px">聊天室名称</td>
                                    <td style =" width :30%; height :20px">用户ID</td>
                                    <td style =" width :30%; height :20px">用户昵称</td>
                                </tr>
                            </table>
                            <table id="CommonChatUserDataList" class ="datalist " style =" width :300px; border:solid 1px #ECECEC;">
                                <tr>
                                    <td>
                                        <div id="CommonChatUserDataListDiv">
                                            对不起，该聊天室没有用户！
                                        </div>                                         
                                    </td>
                                </tr>
                            </table>
                            <div style =" width :100%; background-color :lightGray; height :30px; vertical-align :middle ;">
                                <input  type ="button"  value="全选" class ="chatToolButton " onclick ="chatSelectAll('CommonChatUserDataListDiv');"/>
                                <input  type ="button"  value="反选" class ="chatToolButton " onclick ="chatSelectOthers('CommonChatUserDataListDiv');"/>
                                <input  type ="button"  value="强制下线" class ="chatToolButton " onclick ="commonForceChatUserUnline();"/>
                            </div>
                        </td>
                    </tr>
                 </table>          
            </div>            
        </div>
        <div>
            <input type ="button"  id="freshSubmit"  value="刷新"  onclick ="fresh();"/>
        </div>
   </div>
    <script src="js/cookies.js" type="text/javascript"></script>
   <script  type ="text/javascript" >
       function selectTag(showContent, selfObj) {
           // 标签
           var tag = document.getElementById("tags").getElementsByTagName("li");
           var taglength = tag.length;
           for (i = 0; i < taglength; i++) {
               tag[i].className = "";
           }
           selfObj.parentNode.className = "selectTag";
           // 标签内容
           for (i = 0; i < taglength; i++) {
               j = document.getElementById("tagContent" + i);
               j.style.display = "none";
           }
           document.getElementById(showContent).style.display = "block";
           setCookie("tagContentID", showContent, "");
       }
       var tagContentId = getcookie("tagContentID");
       var index=0;
       if(tagContentId .length>10)
         index = parseInt(tagContentId.substr(10, tagContentId.length - 10));
       var anchList = document.getElementById("tags").getElementsByTagName("a");
       selectTag(tagContentId, anchList[index ]);
       
       var personalDataListId = "ctl00_ctl00_ContentPlaceHolder1_BodyContentPlaceHolder_PersonalChatDataList";
       var personalDataListTable = document.getElementById(personalDataListId); 
       var commonDataListId = "ctl00_ctl00_ContentPlaceHolder1_BodyContentPlaceHolder_CommonChatDataList";
       var commonDataListTable = document.getElementById(commonDataListId);
       var commonUserDataListID = "CommonChatUserDataList";
       var commonUserDataListTable = document.getElementById(commonUserDataListID);
       function chatSelectAll(datalistID) {
           var pTabsInDList = document.getElementById(datalistID).getElementsByTagName('table');
           for (var i = 0; i < pTabsInDList.length; i++) {
               var checkboxtd = pTabsInDList[i].getElementsByTagName('td')[0];
               var checkbox = checkboxtd.getElementsByTagName("input")[0];
               if (checkbox.type == "checkbox")
                   checkbox.checked = true;
           }
       }
       function chatSelectOthers(datalistID) {
           var pTabsInDList = document.getElementById(datalistID).getElementsByTagName('table');
           for (var i = 0; i < pTabsInDList.length; i++) {
               var checkboxtd = pTabsInDList[i].getElementsByTagName('td')[0];
               var checkbox = checkboxtd.getElementsByTagName("input")[0];
               if (checkbox.type == "checkbox")
                   checkbox.checked = !checkbox.checked;
           }
       }
       function personalForceUnline() {
           var pTabsInDList = personalDataListTable.getElementsByTagName('table');
           for (var i = 0; i < pTabsInDList.length; i++) {
               var tdList = pTabsInDList[i].getElementsByTagName('td');
               var checkboxtd = tdList[0];
               var checkbox = checkboxtd.getElementsByTagName("input")[0];
               if (checkbox.type == "checkbox" && checkbox.checked == true) {
                   var userid = tdList[1].innerHTML;
                   chatblog.CommonChat.ChatManage.PersonalForceUnline(userid);
               } 
           }
           fresh();
       }
       function commonForceChatUnline() {
           var pTabsInDList = commonDataListTable.getElementsByTagName('table');
           for (var i = 0; i < pTabsInDList.length; i++) {
               var tdList = pTabsInDList[i].getElementsByTagName('td');
               var checkboxtd = tdList[0];
               var checkbox = checkboxtd.getElementsByTagName("input")[0];
               if (checkbox.type == "checkbox" && checkbox.checked == true) {
                   var roomType = tdList[1].innerHTML;
                   chatblog.CommonChat.ChatManage.CommonForceChatUnline(roomType);
               }
           }
           fresh();
       }
       function commonForceChatUserUnline() {
           var pTabsInDList = document.getElementById('CommonChatUserDataListDiv').getElementsByTagName('table');
           for (var i = 0; i < pTabsInDList.length; i++) {
               var tdList = pTabsInDList[i].getElementsByTagName('td');
               var checkboxtd = tdList[0];
               var checkbox = checkboxtd.getElementsByTagName("input")[0];
               if (checkbox.type == "checkbox" && checkbox.checked == true) {
                   var roomid = checkbox.id;
                   var userid = tdList[2].innerHTML;
                   chatblog.CommonChat.ChatManage.CommonForceChatUserUnline(roomid,userid);
               }
           }
           fresh();
       }
       function selectedRoomID(thisObj) {
           var chatroomObjList = commonDataListTable.getElementsByTagName("table");
           for (var i = 0; i < chatroomObjList.length; i++)
               chatroomObjList[i].bgColor = "";
           thisObj.bgColor = 'blue';
           result = chatblog.CommonChat.ChatManage.GetCommonChatUsersHTML(thisObj.id);
           document.getElementById('CommonChatUserDataListDiv').innerHTML = result.value ;
       }
       function fresh() {
           document.location.href = document.location.href;
       }
   </script>    
</asp:Content>
